home *** CD-ROM | disk | FTP | other *** search
- // (C) Copyright Microsoft Corp. 1991. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that
- // Microsoft has no warranty obligations or liability for any
- // Sample Application Files which are modified.
-
-
- /****************************************************************************
-
- MODULE : Profile.c
-
- PURPOSE : This module is used to retrieve data from initialization files using GetProfileString.
- There are several ini file (playvfw.ini, button#.ini, morph.ini) all of which contain
- data pertaining to a different part of the program.
-
- FUNCTIONS : GetStuffFromIni
- GetPG2FromIni
- ReturnProfileError
- GetVidWinFromIni
- GetDirFromIni
-
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 6/1/93.
-
- ****************************************************************************/
-
- #include "windows.h"
- #include <stdlib.h>
- #include "playvfw.h"
- #include "proto.h"
- #include "mmsystem.h"
- #include <digitalv.h>
- #include <stdio.h>
- #include <time.h>
-
- /****************************************************************************
-
- FUNCTION : GetStuffFromIni(LPDEVICESTRUCT,int,LPSTR)
-
- PURPOSE : This function retrieves information from the playvfw.ini file. This information pertains
- to Buttons 1-6 of the first page and the initial screens VFW button. The infomation retrieved
- is the AVI file, wave file, position of the button, whether to play the video or audio.
- This function also opens the wave file and the AVI file.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 6/15/93
-
- ****************************************************************************/
-
- BOOL FAR PASCAL GetStuffFromIni(lpDevice,nButton,lpPoints)
- LPDEVICESTRUCT lpDevice;
- int nButton;
- LPRECT lpPoints;
-
- {
- HANDLE hBuffer;
- LPSTR lpBuffer;
-
- HANDLE hSection;
- LPSTR lpSection;
-
- HANDLE hFileName;
- LPSTR lpFileName;
-
- HANDLE hEntry;
- LPSTR lpEntry;
-
- HANDLE hAlias;
- LPSTR lpAlias;
-
- HANDLE hExeName;
- LPSTR lpExeName;
-
- HANDLE hExtension;
- LPSTR lpExtension;
-
- HANDLE hNewFile;
- LPSTR lpNewFile;
-
- int nSize;
- int nBytes;
- int nAviFile;
- int nAudioFile;
-
-
- // allocate memory for the different buffers that will be used to get the profile strings from the ini
- // files.
-
- hBuffer=GlobalAlloc(GHND,80);
- hSection=GlobalAlloc(GHND,10);
- hFileName=GlobalAlloc(GHND,128);
- hExtension=GlobalAlloc(GHND,128);
- hNewFile=GlobalAlloc(GHND,128);
- hEntry=GlobalAlloc(GHND,20);
- hAlias=GlobalAlloc(GHND,10);
- hExeName=GlobalAlloc(GHND,10);
-
- if (hBuffer && hSection && hFileName && hEntry && hExtension)
- {
- lpBuffer=GlobalLock(hBuffer);
- lpSection=GlobalLock(hSection);
- lpFileName=GlobalLock(hFileName);
- lpExtension=GlobalLock(hExtension);
- lpNewFile=GlobalLock(hNewFile);
- lpEntry=GlobalLock(hEntry);
- lpAlias=GlobalLock(hAlias);
- lpExeName=GlobalLock(hExeName);
-
- if (lpBuffer && lpSection && lpFileName && lpEntry && lpAlias && lpExtension)
- {
-
- // get the executable name and directory.
-
- nBytes=GetModuleFileName(GetModuleHandle("playvfw.exe"),lpExtension,128);
- if(nBytes)
- {
-
- // look for the section Button# in the ini file.
-
- wsprintf(lpSection,"Button%d",nButton);
-
- // seperate the extension from the exename.
-
- ExtractExtension(lpExtension,lpExeName);
-
- // copy the extension into the filename.
-
- lstrcpy(lpFileName,lpExtension);
-
-
- // check to see if the screen resolution is 640 X 480 if so look in the lowres directory.
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpFileName,"lowres\\");
-
- lstrcat(lpFileName,lpExeName);
-
- // add the filename and the extension of ini (i.e. playvfw.ini).
-
- lstrcat(lpFileName,".ini");
-
- // if it is button 7 (the initial screen button) see if we need to grab a random number. If
- // so lets grab the random # and continue.
-
- if (nButton==7)
- {
- lstrcpy(lpEntry,"Rand");
-
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"TRUE"))
- {
- nAviFile=GetRandNumber123();
- nAudioFile=GetRandNumber123();
- }
- else
- {
- nAviFile=1;
- nAudioFile=1;
- }
- }
- else
- {
- nAviFile=1;
- nAudioFile=1;
- }
-
- // look at the AVI entry and grab the file name.
-
- wsprintf(lpEntry,"AVI File%d",nAviFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- // if we need to add on an additional AVI subdirectory due to the AVI directory entry do it.
-
- if (lstrlen(lpDirs->szAviDir))
- {
- lstrcpy(lpNewFile,lpExtension);
- lstrcat(lpNewFile,lpDirs->szAviDir);
- lstrcat(lpNewFile,"\\");
- lstrcat(lpNewFile,lpBuffer);
- }
- else
- lstrcpy(lpNewFile,lpBuffer);
-
- // need an alias to distinguish between the different AVI files.
-
- wsprintf(lpAlias,"foo%d",nButton);
-
- // open the AVI file.
-
- lpDevice->wDeviceID = OpenVFWFile(hWndMain,wGlobalDeviceID,(LPSTR)lpNewFile,lpAlias);
-
- if (!lpDevice->wDeviceID)
- {
- ReturnDeviceError(lpBuffer,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
-
- // get the wave file.
-
- wsprintf(lpEntry,"Audio File%d",nAudioFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
-
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- // we need to get an alias to distinguish this from other wave files.
-
- wsprintf(lpAlias,"oof%d",nButton);
-
- // add the wave sub directory if there is one.
-
- if (lstrlen(lpDirs->szWavDir))
- {
- lstrcpy(lpNewFile,lpExtension);
- lstrcat(lpNewFile,lpDirs->szWavDir);
- lstrcat(lpNewFile,"\\");
- lstrcat(lpNewFile,lpBuffer);
- }
- else
- lstrcpy(lpNewFile,lpBuffer);
-
- // if the sound device wasn't loaded don't open the wave file. If they specified in the ini
- // file to have no wave playback then don't do this either. Otherwise play the wave file.
-
- if (!bNoSound)
- {
- lpDevice->wAudioDeviceID = OpenWaveFile(wGlobalAudioDeviceID,lpNewFile,lpAlias);
-
- if (!lpDevice->wAudioDeviceID)
- {
- ReturnDeviceError(lpBuffer,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
- }
-
- // grab the position information regarding the button.
-
- wsprintf(lpEntry,"Position%d",nAviFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
- ReturnCoor(lpBuffer,lpPoints);
-
-
- // Should this button be animated?
-
- lstrcpy(lpEntry,"Animation");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
-
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"disabled"))
- lpDevice->bPlayVideo=FALSE;
- else
- lpDevice->bPlayVideo=TRUE;
-
- // should the wave file play for this button?
-
- lstrcpy(lpEntry,"Audio");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"disabled"))
- lpDevice->bPlayAudio=FALSE;
- else
- lpDevice->bPlayAudio=TRUE;
-
- // if the system has no sound then kill the sound even though it may be enabled in the ini file.
-
- if (bNoSound)
- lpDevice->bPlayAudio=FALSE;
-
- } // End if nBytes
- } // End of if the memory locks succeded.
- else
- {
- MessageBox(hWndMain,"Profile string Memory lock failed","ERROR",MB_OK);
- }
- } // End of if the memory allocations succeded.
- else
- MessageBox(hWndMain,"Memory allocation failed for profile strings","ERROR",MB_OK);
-
-
- GlobalUnlock(hFileName);
- GlobalUnlock(hSection);
- GlobalUnlock(hBuffer);
- GlobalUnlock(hEntry);
- GlobalUnlock(hAlias);
- GlobalUnlock(hExeName);
-
- GlobalFree(hFileName);
- GlobalFree(hSection);
- GlobalFree(hBuffer);
- GlobalFree(hEntry);
- GlobalFree(hAlias);
- GlobalFree(hExeName);
-
- return TRUE;
- }
-
- /****************************************************************************
-
- FUNCTION : GetPG2FromIni(LPDEVICESTRUCT,int,LPRECT,LPSTR)
-
- PURPOSE : This function retrieves the information for the last page. It also closes and
- re-opens the wave and video files to conserve on resources.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/1/93
-
- ****************************************************************************/
-
- BOOL FAR PASCAL GetPG2FromIni(lpDevice,nButton,lpPoints,lpIniName)
- LPDEVICESTRUCT lpDevice;
- int nButton;
- LPRECT lpPoints;
- LPSTR lpIniName;
- {
- HANDLE hBuffer;
- LPSTR lpBuffer;
-
- HANDLE hSection;
- LPSTR lpSection;
-
- HANDLE hFileName;
- LPSTR lpFileName;
-
- HANDLE hEntry;
- LPSTR lpEntry;
-
- HANDLE hAlias;
- LPSTR lpAlias;
-
- HANDLE hExeName;
- LPSTR lpExeName;
-
- HANDLE hExtension;
- LPSTR lpExtension;
-
- HANDLE hNewFile;
- LPSTR lpNewFile;
-
- int nSize;
- int nBytes;
- int nAviFile;
- int nAudioFile;
-
- BOOL bReturn;
-
-
-
- hBuffer=GlobalAlloc(GHND,80);
- hSection=GlobalAlloc(GHND,10);
- hFileName=GlobalAlloc(GHND,128);
- hExtension=GlobalAlloc(GHND,128);
- hNewFile=GlobalAlloc(GHND,128);
- hEntry=GlobalAlloc(GHND,20);
- hAlias=GlobalAlloc(GHND,20);
- hExeName=GlobalAlloc(GHND,10);
-
- if (hBuffer && hSection && hFileName && hEntry && hExtension && hNewFile)
- {
- lpBuffer=GlobalLock(hBuffer);
- lpSection=GlobalLock(hSection);
- lpFileName=GlobalLock(hFileName);
- lpExtension=GlobalLock(hExtension);
- lpNewFile=GlobalLock(hNewFile);
- lpEntry=GlobalLock(hEntry);
- lpAlias=GlobalLock(hAlias);
- lpExeName=GlobalLock(hExeName);
-
- if (lpBuffer && lpSection && lpFileName && lpEntry && lpAlias && lpExtension && hNewFile)
- {
- nBytes=GetModuleFileName(GetModuleHandle("playvfw.exe"),lpExtension,128);
- if(nBytes)
- {
- wsprintf(lpSection,"Button%d",nButton);
- ExtractExtension(lpExtension,lpExeName);
- lstrcpy(lpFileName,lpExtension);
-
- if (lstrlen(lpDirs->szIniDir))
- {
-
- lstrcat(lpFileName,lpDirs->szIniDir);
- lstrcat(lpFileName,"\\");
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpFileName,"lowres\\");
-
- }
-
-
-
- lstrcat(lpFileName,lpIniName);
-
- lstrcat(lpFileName,".ini");
-
- // special code if this is the morph window. Since the morph window can pick from 3 different
- // AVI files.
-
- if(!lstrcmp(lpIniName,"morph"))
- {
- lstrcpy(lpEntry,"Rand");
-
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"TRUE"))
- {
- nAviFile=GetRandNumber123();
- nAudioFile=GetRandNumber123();
- }
- else
- {
- nAviFile=1;
- nAudioFile=1;
- }
- }
- else
- {
- nAviFile=1;
- nAudioFile=1;
- }
-
- wsprintf(lpEntry,"AVI File%d",nAviFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpIniName,"morph"))
- wsprintf(lpAlias,"for%d",nButton);
- else
- wsprintf(lpAlias,"%s%d",lpIniName,nButton);
-
- if (lstrlen(lpDirs->szAviDir))
- {
- lstrcpy(lpNewFile,lpExtension);
- lstrcat(lpNewFile,lpDirs->szAviDir);
- lstrcat(lpNewFile,"\\");
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpNewFile,"lowres\\");
-
- lstrcat(lpNewFile,lpBuffer);
- }
- else
- lstrcpy(lpNewFile,lpBuffer);
-
-
- if(lpDevice->wDeviceID)
- {
-
-
- bReturn = CloseVFWFile(lpDevice->wDeviceID);
- }
-
-
- lpDevice->wDeviceID = OpenVFWFile(hWndMain,wGlobalDeviceID,(LPSTR)lpNewFile,lpAlias);
-
- if (!lpDevice->wDeviceID)
- {
- ReturnDeviceError(lpBuffer,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
-
- wsprintf(lpEntry,"Audio File%d",nAudioFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
-
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if (lstrlen(lpDirs->szWavDir))
- {
- lstrcpy(lpNewFile,lpExtension);
- lstrcat(lpNewFile,lpDirs->szWavDir);
- lstrcat(lpNewFile,"\\");
- lstrcat(lpNewFile,lpBuffer);
- }
- else
- lstrcpy(lpNewFile,lpBuffer);
-
-
- if(!lstrcmp(lpIniName,"morph"))
- wsprintf(lpAlias,"%s%d",lpIniName,nButton);
- else
- wsprintf(lpAlias,"oof%d",nButton);
-
-
- if (!bNoSound)
- {
-
- if(lpDevice->wAudioDeviceID)
- {
-
- bReturn = CloseWaveFile(lpDevice->wAudioDeviceID);
- }
-
- lpDevice->wAudioDeviceID = OpenWaveFile(wGlobalAudioDeviceID,lpNewFile,lpAlias);
-
- if (!lpDevice->wAudioDeviceID)
- {
- ReturnDeviceError(lpBuffer,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
- }
-
- wsprintf(lpEntry,"Position%d",nAviFile);
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
- ReturnCoor(lpBuffer,lpPoints);
-
- lstrcpy(lpEntry,"Animation");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
-
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"disabled"))
- lpDevice->bPlayVideo=FALSE;
- else
- lpDevice->bPlayVideo=TRUE;
-
- lstrcpy(lpEntry,"Audio");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if(!lstrcmp(lpBuffer,"disabled"))
- lpDevice->bPlayAudio=FALSE;
- else
- lpDevice->bPlayAudio=TRUE;
-
- // if the system has no sound then kill the sound even though it may be enabled in the ini file.
-
- if (bNoSound)
- lpDevice->bPlayAudio=FALSE;
-
-
- if(lstrcmp(lpIniName,"morph"))
- {
- lstrcpy(lpEntry,"FileName");
-
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",(LPSTR)lpDevice->szFileName,24,lpFileName);
- if(!nSize)
- {
- lstrcpy(lpBuffer,lpDevice->szFileName);
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- //StripSpaces((LPSTR)lpDevice->szFileName);
- }
- //lstrcpy(lpDevice->FileName,lpBuffer);
-
- } // End if nBytes
- } // End of if the memory locks succeded.
- else
- {
- MessageBox(hWndMain,"Profile string Memory lock failed","ERROR",MB_OK);
- }
- } // End of if the memory allocations succeded.
- else
- MessageBox(hWndMain,"Memory allocation failed for profile strings","ERROR",MB_OK);
-
-
- GlobalUnlock(hFileName);
- GlobalUnlock(hSection);
- GlobalUnlock(hBuffer);
- GlobalUnlock(hEntry);
- GlobalUnlock(hAlias);
- GlobalUnlock(hExeName);
-
- GlobalFree(hFileName);
- GlobalFree(hSection);
- GlobalFree(hBuffer);
- GlobalFree(hEntry);
- GlobalFree(hAlias);
- GlobalFree(hExeName);
-
- return TRUE;
- }
-
- /****************************************************************************
-
- FUNCTION : ReturnProfileError(LPSTR ,LPSTR ,LPSTR ,HANDLE ,HANDLE ,HANDLE ,HANDLE ,HANDLE )
-
- PURPOSE : This function returns an error if it can't find the entry or section in the ini file.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/15/93
-
- ****************************************************************************/
-
-
- void FAR PASCAL ReturnProfileError(LPSTR lpEntry,LPSTR lpSection,LPSTR lpFileName,HANDLE hFileName,HANDLE hSection,HANDLE hBuffer,HANDLE hExeName,HANDLE hAlias)
- {
-
- HANDLE hBuf;
- LPSTR lpBuf;
-
- hBuf=GlobalAlloc(GHND,255);
- if(!hBuf)
- return;
-
- lpBuf=GlobalLock(hBuf);
-
- if (!lpBuf)
- return;
-
- wsprintf(lpBuf,"The %s entry for %s was omitted in the %s file. Please edit the ini file.",lpEntry,lpSection,lpFileName);
- MessageBox(hWndMain,lpBuf,"ERROR",MB_OK);
-
- GlobalUnlock(hFileName);
- GlobalUnlock(hSection);
- GlobalUnlock(hBuffer);
- GlobalUnlock(hExeName);
- GlobalUnlock(hAlias);
- GlobalUnlock(hBuf);
-
- GlobalFree(hFileName);
- GlobalFree(hSection);
- GlobalFree(hBuffer);
- GlobalFree(hExeName);
- GlobalFree(hAlias);
- GlobalFree(hBuf);
-
- return;
- }
-
- /****************************************************************************
-
- FUNCTION : GetVidWinFromIni(LPDEVICESTRUCT,int,LPRECT,LPRECT,LPRECT,LPSTR)
-
- PURPOSE : This function retrieves the information for the Video Window on the last page.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/1/93
-
- ****************************************************************************/
-
- BOOL FAR PASCAL GetVidWinFromIni(lpDevice,nButton,lpPoints,lpPoints2,lpPoints3,lpIniName)
- LPDEVICESTRUCT lpDevice;
- int nButton;
- LPRECT lpPoints;
- LPRECT lpPoints2;
- LPRECT lpPoints3;
- LPSTR lpIniName;
- {
- HANDLE hBuffer;
- LPSTR lpBuffer;
-
- HANDLE hSection;
- LPSTR lpSection;
-
- HANDLE hFileName;
- LPSTR lpFileName;
-
- HANDLE hEntry;
- LPSTR lpEntry;
-
- HANDLE hAlias;
- LPSTR lpAlias;
-
- HANDLE hExeName;
- LPSTR lpExeName;
-
- HANDLE hExtension;
- LPSTR lpExtension;
-
- HANDLE hNewFile;
- LPSTR lpNewFile;
-
- int nSize;
- int nBytes;
- int nAviFile;
- int nAudioFile;
-
- //BOOL bReturn;
-
-
- //nAviFile=GetRandNumber123();
- nAviFile=1;
- //nAudioFile=GetRandNumber123();
- nAudioFile=1;
-
- hBuffer=GlobalAlloc(GHND,80);
- hSection=GlobalAlloc(GHND,10);
- hFileName=GlobalAlloc(GHND,128);
- hExtension=GlobalAlloc(GHND,128);
- hNewFile=GlobalAlloc(GHND,128);
- hEntry=GlobalAlloc(GHND,20);
- hAlias=GlobalAlloc(GHND,20);
- hExeName=GlobalAlloc(GHND,10);
-
- if (hBuffer && hSection && hFileName && hEntry && hExtension && hNewFile)
- {
- lpBuffer=GlobalLock(hBuffer);
- lpSection=GlobalLock(hSection);
- lpFileName=GlobalLock(hFileName);
- lpExtension=GlobalLock(hExtension);
- lpNewFile=GlobalLock(hNewFile);
- lpEntry=GlobalLock(hEntry);
- lpAlias=GlobalLock(hAlias);
- lpExeName=GlobalLock(hExeName);
-
- if (lpBuffer && lpSection && lpFileName && lpEntry && lpAlias && lpExtension && lpNewFile)
- {
- nBytes=GetModuleFileName(GetModuleHandle("playvfw.exe"),lpExtension,128);
- if(nBytes)
- {
- wsprintf(lpSection,"Button%d",nButton);
- ExtractExtension(lpExtension,lpExeName);
- lstrcpy(lpFileName,lpExtension);
-
- if (lstrlen(lpDirs->szIniDir))
- {
- lstrcat(lpFileName,lpDirs->szIniDir);
- lstrcat(lpFileName,"\\");
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpFileName,"lowres\\");
- }
-
- lstrcat(lpFileName,lpIniName);
- // put in check for a exe file already 8 characters long.
- //lstrcat(lpFileName,"2");
- lstrcat(lpFileName,".ini");
-
- wsprintf(lpEntry,"AVI File");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
- if (lstrlen(lpDirs->szAviDir))
- {
- lstrcpy(lpNewFile,lpExtension);
- lstrcat(lpNewFile,lpDirs->szAviDir);
- lstrcat(lpNewFile,"\\");
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpNewFile,"lowres\\");
-
- lstrcat(lpNewFile,lpBuffer);
- }
- else
- lstrcpy(lpNewFile,lpBuffer);
-
- wsprintf(lpAlias,"VidWin%d",nButton);
-
-
-
- lpDevice->wDeviceID = OpenVFWFile(hWndMain,wGlobalDeviceID,(LPSTR)lpNewFile,lpAlias);
-
- if (!lpDevice->wDeviceID)
- {
- ReturnDeviceError(lpBuffer,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
-
-
- wsprintf(lpEntry,"Position");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
- ReturnCoor(lpBuffer,lpPoints);
-
- lstrcpy(lpEntry,"ControlPos");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
- ReturnCoor(lpBuffer,lpPoints2);
-
- wsprintf(lpEntry,"EditPosition");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
- ReturnCoor(lpBuffer,lpPoints3);
-
- } // End if nBytes
- } // End of if the memory locks succeded.
- else
- {
- MessageBox(hWndMain,"Profile string Memory lock failed","ERROR",MB_OK);
- }
- } // End of if the memory allocations succeded.
- else
- MessageBox(hWndMain,"Memory allocation failed for profile strings","ERROR",MB_OK);
-
-
- GlobalUnlock(hFileName);
- GlobalUnlock(hSection);
- GlobalUnlock(hBuffer);
- GlobalUnlock(hEntry);
- GlobalUnlock(hAlias);
- GlobalUnlock(hExeName);
-
- GlobalFree(hFileName);
- GlobalFree(hSection);
- GlobalFree(hBuffer);
- GlobalFree(hEntry);
- GlobalFree(hAlias);
- GlobalFree(hExeName);
-
- return TRUE;
- }
-
- /****************************************************************************
-
- FUNCTION : GetDirFromIni(LPDIRSTRUCT,LPSTR)
-
- PURPOSE : This function gets the directory entries in the ini file.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/1/93.
-
- ****************************************************************************/
-
- BOOL FAR PASCAL GetDirFromIni(lpDirs,lpIniName)
- LPDIRSTRUCT lpDirs;
- LPSTR lpIniName;
- {
- HANDLE hBuffer;
- LPSTR lpBuffer;
-
- HANDLE hSection;
- LPSTR lpSection;
-
- HANDLE hFileName;
- LPSTR lpFileName;
-
- HANDLE hEntry;
- LPSTR lpEntry;
-
- HANDLE hAlias;
- LPSTR lpAlias;
-
- HANDLE hExeName;
- LPSTR lpExeName;
-
- int nSize;
- int nBytes;
- int nAviFile;
- int nAudioFile;
-
- //BOOL bReturn;
-
-
-
- nAviFile=GetRandNumber123();
- nAviFile=1;
- nAudioFile=GetRandNumber123();
- nAudioFile=1;
-
- hBuffer=GlobalAlloc(GHND,80);
- hSection=GlobalAlloc(GHND,10);
- hFileName=GlobalAlloc(GHND,128);
- hEntry=GlobalAlloc(GHND,20);
- hAlias=GlobalAlloc(GHND,20);
- hExeName=GlobalAlloc(GHND,10);
-
- if (hBuffer && hSection && hFileName && hEntry)
- {
- lpBuffer=GlobalLock(hBuffer);
- lpSection=GlobalLock(hSection);
- lpFileName=GlobalLock(hFileName);
- lpEntry=GlobalLock(hEntry);
- lpAlias=GlobalLock(hAlias);
- lpExeName=GlobalLock(hExeName);
-
- if (lpBuffer && lpSection && lpFileName && lpEntry && lpAlias)
- {
- nBytes=GetModuleFileName(GetModuleHandle("playvfw.exe"),lpFileName,128);
- if(nBytes)
- {
- lstrcpy(lpSection,"FILES");
- ExtractExtension(lpFileName,lpExeName);
-
- //if (GetSystemMetrics(SM_CXSCREEN)==640)
- if(!fHiResCapable())
- lstrcat(lpFileName,"lowres\\");
-
- lstrcat(lpFileName,lpIniName);
- // put in check for a exe file already 8 characters long.
- //lstrcat(lpFileName,"2");
- lstrcat(lpFileName,".ini");
-
- lstrcpy(lpEntry,"AVI");
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
- StripSpaces(lpBuffer);
-
-
-
- lstrcpy(lpDirs->szAviDir,lpBuffer);
-
-
-
- lstrcpy(lpEntry,"INI");
-
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
-
-
- lstrcpy(lpDirs->szIniDir,lpBuffer);
-
- lstrcpy(lpEntry,"WAV");
-
- nSize=GetPrivateProfileString(lpSection,lpEntry,"",lpBuffer,80,lpFileName);
- if(!nSize)
- {
- ReturnProfileError(lpEntry,lpSection,lpFileName,hFileName,hSection,hBuffer,hExeName,hAlias);
- return FALSE;
- }
-
-
- lstrcpy(lpDirs->szWavDir,lpBuffer);
-
- } // End if nBytes
- } // End of if the memory locks succeded.
- else
- {
- MessageBox(hWndMain,"Profile string Memory lock failed","ERROR",MB_OK);
- }
- } // End of if the memory allocations succeded.
- else
- MessageBox(hWndMain,"Memory allocation failed for profile strings","ERROR",MB_OK);
-
-
- GlobalUnlock(hFileName);
- GlobalUnlock(hSection);
- GlobalUnlock(hBuffer);
- GlobalUnlock(hEntry);
- GlobalUnlock(hAlias);
- GlobalUnlock(hExeName);
-
- GlobalFree(hFileName);
- GlobalFree(hSection);
- GlobalFree(hBuffer);
- GlobalFree(hEntry);
- GlobalFree(hAlias);
- GlobalFree(hExeName);
-
- return TRUE;
- }
-
-